package 力扣91;

/**
 * @ClassName : Day10_160_相交链表_朴素双重for循环
 * @Author : 骆发茂
 * @Date: 2021/12/22 21:34
 * @Description : *这里要注意是节点相同，地址和值都要相同。
 * https://leetcode-cn.com/problems/intersection-of-two-linked-lists/solution/
 * https://leetcode-cn.com/problems/intersection-of-two-linked-lists/solution/gong-shui-san-xie-zhao-liang-tiao-lian-b-h3bd/
 */
public class Day10_160_相交链表_朴素双重for循环 {
    public class Solution {
        public ListNode getIntersectionNode(ListNode headA, ListNode headB) {
            for (ListNode h1 = headA; h1 != null; h1 = h1.next) {
                for (ListNode h2 = headB; h2 != null; h2 = h2.next) {
                    if (h1.equals(h2)) return h1;
                }
            }
            return null;
        }
    }
}